package vcp.gui.panels;


import java.awt.Color;
import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.GridLayout;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.Random;

import javax.swing.JPanel;

import db.parking.beans.ParkingLot;
import vcp.controllers.SaveParkingController;
import vcp.gui.components.VCPPanel;

/**
 * Parking grid widget
 *
 */
public class PnlParkingGrid extends VCPPanel {
	
	private static final long serialVersionUID = 1L;

	/**
	 * make parking grid , uses cell panes 
	 * @param pl
	 * @param controller
	 */
	public PnlParkingGrid(ParkingLot pl, SaveParkingController controller) {
		int [][]floor = pl.getFloor();
		setLayout(new GridLayout(floor[0].length,floor.length,5,5));
		for (int i = 0; i < floor[0].length; i++) {
		    for (int j = 0; j < floor.length; j++) {
		    	pnlCellPane pnl; 
		    	if(floor[j][i]==0)
		    		pnl = new pnlCellPane(pl,Color.green,i,j,floor[j][i]);
		    	else if(floor[j][i]==1)
		    		pnl = new pnlCellPane(pl,Color.gray,i,j,floor[j][i]);
		    	else if(floor[j][i]==2)
		    		pnl = new pnlCellPane(pl,Color.red,i,j,floor[j][i]);
		    	else
		    		pnl = new pnlCellPane(pl,Color.blue,i,j,floor[j][i]);
		    	pnl.addMouseListener((MouseListener) controller);
				add(pnl);
				//System.out.print(floorMatrix[j][i]);
		    }
		  // System.out.println();
		}
    }
}



